import json

import pytest

from APIs.logAPI import Log
from APIs.loginAPI import Login
from datas.file.du import DoExe

f = r"D:\2501\apiauto\datas\file\接口测试悟空.xlsx"
# myjson = DoExe().doExeRead(f, "addlog", 2, 13, 3, 7)
myjson = DoExe().doExeRead(f, "updatelog", 2, 12, 3, 7)
# myjson = DoExe().doExeRead(f, "chalog", 2, 12, 3, 7)
# mydata = DoExe().doExeRead(f, "dlelog", 2, 12, 3, 7)


class TestxinLog():

    # @pytest.mark.parametrize("title,url,method,myjson,yq", myjson)
    # def testxinLog(self, title, url, method, myjson, yq):
    #     myjson = json.loads(myjson)
    #     lg = Login().get_token()
    #     a = Log(token=lg).xinLog(myjson)
    #     assert a == yq

    @pytest.mark.parametrize("title,url,method,myjson,yq", myjson)
    def testupLog(self, title, url, method, myjson, yq):
        myjson = json.loads(myjson)
        lg = Login().get_token()
        myjson["logId"] = Log(token=lg).get_logId()
        myjson["batchId"] = Log(token=lg).Files()
        a = Log(token=lg).updateLog(myjson)
        assert a == yq
    # @pytest.mark.parametrize("title,url,method,myjson,yq", myjson)
    # def testselLog(self,title,url,method,myjson,yq):
    #     myjson = json.loads(myjson)
    #     lg = Login().get_token()
    #     a = Log(token=lg).selLog(myjson)
    #     assert a == yq
    # @pytest.mark.parametrize("title,url,method,mydata,yq", mydata)
    # def testDelLog(self, title, url, method, mydata, yq):
    #     mydata = json.loads(mydata)
    #     lg = Login().get_token()
    #     mydata["logId"]=Log(token=lg).get_logId()
    #     a = Log(token=lg).delLog(mydata)
    #     assert a == yq